<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
</head>
<body>
<form id="udp_form">
    输入旧密码：<input type="password"  id="chan2" name="password1"><br>
    输入新密码：<input type="password"  id="chan1"><br>
    确认新密码：<input type="password" name="password" id="chan"><p id="message"></p><br>
    <button id="but-upd" type="button">修改</button>
</form>
<script src="../bootstrap/jquery3.6.js"></script>
<script src="../bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="../bootstrap/vue.js"></script>
<script>

    $('#chan1').change(function(){
        if($("#chan2").val()==$("#chan1").val()){
            $("#message").text("不能与原密码相同")
        }else{
            $("#message").text("");
        }
    })
    $("#chan").change(function (){
        if($("#chan").val()!=$("#chan1").val()){
            $("#message").text("两次输入的密码不对")
        } else{
            $("#message").text("");
        }
    })
    if($("#chan").val()==$("#chan1").val()){
        $("#but-upd").click(function (){
            $.ajax({
                type:"post",
                data:$("#udp_form").serialize(),
                url:"../Menu/updpas",
                dataType:"json",
                success:(function (json){
                    if (json.message.toString()==""){
                        alert("密码修改成功");
                        window.top.location.href="../Login.html";
                    }else{
                        alert(json.message);
                    }
                })
            })
        })
    }else{
        $("#message").text("两次输入的密码不对")
    }


</script>
</body>
</html>